package com.bwie.controller;

import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginVo;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.RegInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/7/18 11:29
 */

@RestController
@RequestMapping(value = "/user/index")
@Slf4j
public class IndexController {

    @Autowired
    TbUserService tbUserService;

    /**
     * @description 发送验证码
     * @params [mobile]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/18 11:31
     */
    @PostMapping(value = "/sendCode/{mobile}")
    public R sendCode(@PathVariable("mobile") String mobile) {
        return tbUserService.sendCode(mobile);
    }

    /**
     * @description 用户注册
     * @params [regInfoVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/18 11:45
     */
    @PostMapping(value = "/userReg")
    public R userReg(@RequestBody @Validated RegInfoVo regInfoVo) {
        return tbUserService.userReg(regInfoVo);
    }

    /**
     * @description 用户登陆
     * @params [loginVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/18 15:06
     */
    @PostMapping(value = "/userLogin")
    public R userLogin(@RequestBody @Validated LoginVo loginVo) {
        return tbUserService.userLogin(loginVo);
    }

    /**
     * @description 获取当前用户的菜单树
     * @params []
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/19 11:52
     */
    @PostMapping(value = "/getMenuTree")
    public R getMenuTree() {
        return tbUserService.getMenuTree();
    }

    /**
     * @description 商家列表
     * @params [pageInfoVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/21 11:45
     */
    @PostMapping(value = "/getShopperList")
    public R getShopperList(@RequestBody PageInfoVo pageInfoVo) {
        return tbUserService.getShopperList(pageInfoVo);
    }
}
